﻿
Partial Class UCContent
    Inherits System.Web.UI.UserControl

    Public Sub Display(p As CProduct)
        lnkText.NavigateUrl = CSitemap.Decide(p)


        lnkAudio.Visible = p.Files.HasMp3
        If lnkAudio.Visible Then lnkAudio.NavigateUrl = CConfig.DropboxUrl(p.Files.FirstMp3.FileName)

        lnkManual.Visible = p.Files.HasPdfOrWord 'OrElse p.Children.Manuals.Count > 0
        If lnkManual.Visible Then lnkManual.NavigateUrl = CConfig.DropboxUrl(p.Files.FirstPdfOrWord.FileName)

        lnkVideo.Visible = p.HasVideos OrElse p.Children.HavingVideos.Count > 0 'OrElse p.Children.Teachings.Count > 0
        If lnkVideo.Visible Then lnkVideo.NavigateUrl = p.VideoUrl

        If (lnkAudio.Visible Or lnkManual.Visible Or lnkVideo.Visible) = False Then
            lnkManual.Visible = p.Files.HasHtm
            If lnkManual.Visible Then lnkManual.NavigateUrl = CConfig.DropboxUrl(p.Files.FirstHtm.FileName)
        End If

        lnkScript.Visible = p.HasTranscript
        If lnkScript.Visible Then lnkScript.NavigateUrl = lnkText.NavigateUrl & "#transcript"

        lnkText.Text = CUtilities.Truncate(p.ProductName, 42)
        lnkText.ToolTip = String.Concat(p.ProductNameAndContents, vbCrLf, " (", p.TypeName, ")")
        lnkAlt.Text = p.ProductNameChineseSimplified
        lnkAlt.NavigateUrl = lnkText.NavigateUrl

        If Not p.HasParent Then
            lnkText.Font.Size = New FontUnit("16px")
            lnkText.Style.Add("vertical-align", "top")
            lnkAudio.NavigateUrl = lnkText.NavigateUrl
            lnkManual.NavigateUrl = lnkText.NavigateUrl
            lnkVideo.NavigateUrl = lnkText.NavigateUrl
            lnkScript.NavigateUrl = lnkText.NavigateUrl
        End If

        'If isMobile AndAlso p.IsSet Then lnkText.Text = lnkText.Text.Replace(" (", "<br> (")
        'If p.HasImage Then
        '    lnkThumb.Visible = True
        '    lnkText.Visible = showText
        '    lnkThumb.NavigateUrl = lnkText.NavigateUrl
        '    lnkThumb.ImageUrl = CSitemap.ProductTiny(p)
        '    lnkThumb.ToolTip = p.ProductNameAndPrice
        '    lnkThumb.Style.Add("display", "block")
        'End If
    End Sub
End Class
